
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@page import="com.tss.util.*"%>
<%@page import="com.jedi.*"%>
<%@page import="com.store.*"%>
<%@page import="java.util.*"%>
<%@page import="java.text.*"%>
<%@include file="../global_var.jsp"%>
<%@include file="../check_login.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

String parent_id = ParamUtils.getParameter(request,"parent_id","");
ArticleMgr articleMgr = new ArticleMgr();
ArticleCateMgr cateMgr = new ArticleCateMgr();
List list = null;
User just_user = (User)session.getAttribute("LoginUser");
String power_enable_id = "10802";
if (!just_user.hasPower(power_enable_id)) {
	out.println(strNoPowerInfo); 
	return;
}
ArticleCategory parentCate = cateMgr.get(parent_id);
String list_title = "文章列表";
if (parentCate != null && !parentCate.getId().equals(""))
	list_title = parentCate.getCategoryName();

String category_id = ParamUtils.getParameter(request,"category_id","");
String keyval = ParamUtils.getParameter(request,"keyval","");
%>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<link href="style/main.css" rel="stylesheet" type="text/css">
<script language="javascript" src="js/common.js"></script>
<script language="javascript">
function clk_artcle_show(article_id) {
	location.href = "know_article_modi.jsp?article_id=" + article_id;
}

function clk_search() {
	var sForm = document.searchForm;
	try {
		var oForm = document.pageForm;
		oForm.category_id.value = sForm.category_id.options[sForm.category_id.selectedIndex].value;
		oForm.keyval.value = sForm.keyval.value;
		oForm.submit();
	}
	catch(ex) {
		//alert(ex.description);
		sForm.submit();
	}
}
</script>
</head>
<body 
	leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td style="padding-left:25px;">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td height="31" valign="top" background="images/title_bk_01.gif"
					style="padding-left:10px;padding-top:6px;">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td width="50%" style="color:#FFFFFF;font-size:13px;"><b>知识库</b>
						-&gt; <b><%=list_title%></b></td>
						<td width="50%" align="right" style="padding-right:10px;">&nbsp; <span
							onclick="right_menu_clk('know_article_add.jsp?cate_id=<%=parent_id%>');"
							style="cursor:hand;color:#FFFFFF;font-size:12px;text-de--ation: underline;">添加文章</span>
						</td>
					</tr>
				</table>
				</td>
			</tr>
			<tr>
				<td height="100" align="right" valign="top"
					style="padding-top:12px;padding-bottom:10px;padding-right:5px;">
				<form name="searchForm" method="post">
				<table width="100%" border="0" cellpadding="0" cellspacing="1"
					bgcolor="#CCCCCC">
					
					<tr bgcolor="#EDEDF0">
						<td height="30" style="padding-left:10px;" colspan="4">查找 -->
						&nbsp;&nbsp; <select name="category_id" onchange="clk_search();">
							<option value="">全部分类</option>
							<%
                    List cateList = cateMgr.get(" and parent_id = '" + parent_id + "' and is_leaf = 1","order_id");
                    if (cateList != null && cateList.size() > 0) {
                    	for(int j=0;j<cateList.size();j++) {
                    		ArticleCategory cateItem = (ArticleCategory)cateList.get(j);
                    %>
							<option value="<%=cateItem.getId()%>"
								<%if (category_id.equals(cateItem.getId())){%> selected <%}%>><%=cateItem.getCategoryName()%></option>
							<%
                    	}
                    }%>
						</select> &nbsp;&nbsp; 标题： <input name="keyval" type="text"
							class="inputbox" value="<%=keyval%>" size="20" maxlength="25"> <input
							type="button" name="button" value="搜　索" class="inputButton"
							onclick="clk_search();"></td>
					</tr>
					
				</table>
				</form>
				<table width="100%" border="0" cellpadding="0" cellspacing="1"
					bgcolor="#FFFFFF">
					<tr bgcolor="#858585" align="center">
						<td height="24" width="40%" style="color:#FFFFFF;"><b>文章标题</b></td>
						<td width="23%" style="color:#FFFFFF;"><b>发布时间</b></td>
						<td width="18%" style="color:#FFFFFF;"><b>所属分类</b></td>
						<td width="10%" style="color:#FFFFFF;"><b>点击数</b></td>
						<td width="10%" style="color:#FFFFFF;"><b>操作</b></td>
					</tr>
					<%
              String otherSQL = " and b.parent_id = '" + parent_id + "'";
              if (category_id != null && !category_id.trim().equals("")) 
              	otherSQL += " and a.category_id = '" + category_id + "'";
              if (keyval != null && !keyval.trim().equals("")) 
              	otherSQL += " and a.article_title like '%" + keyval + "%'";
              String orderField = "a.category_id,issue_time desc";
              int pageSize = 10;
              int pageNo = ParamUtils.getIntParameter(request,"page",1);
              list = articleMgr.get(otherSQL,orderField,pageNo,pageSize);
              int total = articleMgr.getTotal(); 
              boolean b=(total % pageSize ==0);
              int pageCount=b?(total/pageSize):(total/pageSize +1);
              if(pageNo>pageCount){
              	pageNo=pageCount;
              }
              if (list != null && list.size() > 0) {
              	String bgColor[] = {"#EDEDF0","#D7D7DB"};
              	for(int i=0;i<list.size();i++) {
              		Article item = (Article)list.get(i);
              %>
					<tr bgcolor="<%=bgColor[i%2]%>" align="center">
						<td height="24"><a
							href="knowledge_mgt/know_article_show.jsp?article_id=<%=item.getId()%>"><%=item.getArticleTitle()%></a></td>
						<td><%=item.getIssueTime()%></td>
						<td><%=item.getCategory().getCategoryName()%></td>
						<td><%=item.getHit()%></td>
						<td><span onclick="clk_artcle_show('<%=item.getId()%>');"
							style="cursor:hand;text-decoration: underline;">操作</span></td>
					</tr>
					<%	}%>
				</table>
				<form name="pageForm" method="post">
				<table width="100%" border="0" cellpadding="0" cellspacing="0"
					background="images/page_img/page_bk.gif">
					
					<tr height="32" align="center" valign="bottom">
						<td width="5%"><img src="images/page_img/page_tag_01.gif"> <input
							type="hidden" name="category_id" value="<%=category_id%>"> <input
							type="hidden" name="keyval" value="<%=keyval%>"></td>
						<td height="35" align="right" style="padding-right:10px;"
							valign="bottom" id="pannelPageInfo">&nbsp;</td>
					</tr>
					
				</table>
				</form>
				<script language="javascript">
            pannelPageInfo.innerHTML = getPageInfo(<%=total%>,<%=pageSize%>,<%=pageNo%>,5,'images/page_img','pageForm');
            </script> <%}else{%>
		

		<table width="95%" border="0" cellpadding="4" cellspacing="1"
			bgcolor="#FFFFFF">
			<tr>
				<td height="60" align="center">目前没有发布任何文章信息!</td>
			</tr>
		</table>
		<%}%>
	</td>
	</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
